package com.atguigu.juc.t4;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class Apple {
    public Integer num = 9;

    public void getApple() {
        Lock lock = new ReentrantLock();
        if (this.num > 0) {
            System.out.println(Thread.currentThread().getName() + "摘到了苹果");
            num--;
            System.out.println(Thread.currentThread().getName() + "摘完后还剩余" + num + "个苹果");
        }else {
            System.out.println(Thread.currentThread().getName() + "苹果被摘完了，没有摘到苹果");
        }
    }
}
